import WYapi from "@/utils/request"
import MYapi from "@/utils/my"

import login from "@/utils/login"
export interface CategoryModel {
  category: searchlistModel[]
}

export interface searchlistModel {
  categoryId: number,
  categoryName: string
}

//搜索列表
export interface SearchListModel {
  count: number
  display_type: number
  display_word: string
  intro: string
  is_through: boolean
  outside_hot_search_type: number
  score: number
  shift: number
  tgt_id: number
  through_type: number
  url: string
  word: string
}

// 一级分类列表
export interface oneModel {
  moduleName: string,
  order: number,
  moduleType: string,
  moduleKey: string,
  dataComponentKey: string
}

export interface OnModel {
  data: oneModel[]
}

export interface SearchModel {
  hotWordResultList: SearchListModel[]
}

//搜索结果列表类型
interface SearchResModel {
  data: { result: SearchResultModel }
  msg: string
  ret: number
}
interface SearchResultModel {
  albumResultList: AlbumResultModel[]
  albumResultNum: number
  queryResultList: QueryResultModel[]
  queryResultNum: number
}
export interface QueryResultModel {
  highlightKeyword: string
  id: number
  keyword: string
  recallCount: number
}
export interface AlbumResultModel {
  category: string
  highlightKeyword: string
  id: number
  imgPath: string
  isNoCopyright: boolean
  is_paid: boolean
  keyword: string
  play: number
  tracks: number
  url: string
}



//获取搜索页头部数据
export const getsearchlist = () => {
  return WYapi.get<any, CategoryModel>('hotWordBillboardCategory')
}
//获取搜索页下拉列表
export const reqSearchList = (categoryId: string, size: number) => {
  return WYapi.get<any, SearchModel>(`hotWordBillboard/list/2.0?categoryId=${categoryId}&size=${size}`)
}
// 某个分类下的关键字列表 https://search.ximalaya.com/hotWordBillboard/list/2.0?categoryId=-1&size=24
export const reqkeywordList = (categoryId: number) => {
  return WYapi.get<any, SearchModel>(`hotWordBillboard/list/2.0?categoryId=${categoryId}&size=24`)
}
//获取一级分类列表 https://m.ximalaya.com/m-revision/page/index/queryIndexTabModule
export const reqonelist = () => {
  return WYapi.get<any, OnModel>('https://m.ximalaya.com/m-revision/page/index/queryIndexTabModule')
}

//根据搜索内容请求数据
export const getSearsh = (kw: string, paidFilter: boolean, scope: string,) => {
  return MYapi.get<any, SearchResModel>(`/revision/suggest?kw=${kw}&paidFilter=${paidFilter}&scope=${scope}`)
}









//此函数专门用于根据手机号获取验证码
// export const reqGetCode = (phone) => myAxios.get(`/api/user/passport/sendCode/${phone}`)
export const reqGetCode = (phone: string) => {
  return login.get<any>(`/api/user/passport/sendCode/${phone}`)
}
// 该函数专门用于：请求登录(参数为对象，包含：phone，password属性)
// export const reqLogin = (loginParams) => myAxios.post('/api/user/passport/login', loginParams)
export const reqlogin = (loginParams: any) => {
  return login.post<any>(`/api/user/passport/login`, loginParams)
}
// 此函数专门用于注册
// export const reqRegister = (registerParams) => myAxios.post('/api/user/passport/register', registerParams)
// export const reqRegister = (registerParams: any) => {
//   return login.post<any>(`/api/user/passport/register`, registerParams)
// }


